from django.core.paginator import Paginator
from django.shortcuts import render
from .models import StockData

def stock_list(request):
    stocks = StockData.objects.all()  # 获取所有股票数据
    paginator = Paginator(stocks, 50)  # 每页显示 10 条数据
    page_number = request.GET.get('page')  # 获取当前页码
    page_obj = paginator.get_page(page_number)  # 获取当前页的数据
    return render(request, 'stock_app/stock_list.html', {'page_obj': page_obj})